# !/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time : 2023/4/23 9:37
# @Author : xyjiang1216
# @Email : jiangxuyan@nudt.edu.cn
# @File : algo_input_class.py
# @Version: OpenPlanner2.0
from typing import List


class StreamInfo:
    def __init__(self,
                 stream_id: int,
                 hop_id: int):
        self.stream_id: int = stream_id
        self.hop_id: int = hop_id


class Link:
    def __init__(self, **kwargs):
        self.link_id: int = kwargs['link_id']
        self.src_node: int = kwargs['src_node']
        self.dst_node: int = kwargs['dst_node']
        self.speed: int = kwargs['speed']
        self.st_queues: int = kwargs['st_queues']
        if 'src_port' in kwargs:
            self.src_port = kwargs['src_port']
        if 'dst_port' in kwargs:
            self.dst_port = kwargs['dst_port']

        # 经过该链路的流量
        self.stream_array: List[StreamInfo] = []

    def add_stream_to_link(self,
                           stream_at_link: StreamInfo):
        self.stream_array.append(stream_at_link)


class Stream:
    def __init__(self, **kwargs):
        self.stream_id: int = \
            kwargs['stream_id']
        self.size: int = \
            kwargs['size']
        self.period: int = \
            kwargs['period']
        # self.latency_requirement: int = \
        #     kwargs['latency_requirement']
        # self.jitter_requirement: int = \
        #     kwargs['jitter_requirement']
        self.route: List[int] = \
            kwargs['route']


class Instance:
    def __init__(self,
                 stream_id: int,
                 period_id: int,
                 link_id: int):
        self.stream_id: int = stream_id
        self.period_id: int = period_id
        self.link_id: int = link_id


class AlgoInput:
    def __init__(self,
                 # link_array: List[Link],
                 # stream_array: List[Stream],
                 # instance_array: List[List[List[Instance]]]
                 ):
        self.link_array: List[Link] = []
        self.stream_array: List[Stream] = []
        self.instance_array: List[List[List[Instance]]] = []
